package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.dto.response.HotServeListDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeTypeListDTO;
import com.jzo2o.foundations.service.HomeService;
import com.jzo2o.foundations.service.IServeService;
import com.jzo2o.foundations.service.IServeTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequiredArgsConstructor
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务查询接口:用户端 - 首页服务查询接口:用户端 - 首页服务查询接口")
public class ServeController {
    private final IServeTypeService serveTypeService;
    private final IServeService serveService;
    private final HomeService homeService;
    @GetMapping("/firstPageServeList")
    @ApiOperation("首页服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    })
    public List<ServeCategoryResDTO> serveCategory(@RequestParam("regionId") Long regionId) {
        List<ServeCategoryResDTO> serveCategoryResDTOS = homeService.queryServeIconCategoryByRegionIdCache(regionId);
        return serveCategoryResDTOS;
    }

    @ApiOperation("根据地区ID查询服务类型")
    @GetMapping("/serveTypeList")
    public List<ServeTypeListDTO> serveTypeList(Long regionId){
        return serveTypeService.getServeTypeByRegionId(regionId);
    }
    @ApiOperation("查询首页热门服务列表")
    @GetMapping("/hotServeList")
    public List<HotServeListDTO> hotServeList(Long regionId){
        return serveService.hotServeList(regionId);
    }
    @ApiOperation("查询服务详情页面")
    @GetMapping("/{id}")
    public List<HotServeListDTO> serveDetail(@PathVariable String id){
        return serveTypeService.getServeDetail(Long.valueOf(id));
    }
}
